package com.bw.mallshop.widget;

import android.content.Context;
import android.graphics.Color;

import androidx.annotation.Nullable;

import com.yanyusong.y_divideritemdecoration.Y_Divider;
import com.yanyusong.y_divideritemdecoration.Y_DividerBuilder;
import com.yanyusong.y_divideritemdecoration.Y_DividerItemDecoration;

public class HomeGoodsDivider extends Y_DividerItemDecoration {

    public HomeGoodsDivider(Context context) {
        super(context);
    }

    //列表中item索引Position
    @Nullable
    @Override
    public Y_Divider getDivider(int itemPosition) {
        if (itemPosition==0){
            Y_DividerBuilder builder = new Y_DividerBuilder();
            return builder.create();
        }
        if (itemPosition%2!=0){
            //偶数->底部以及右侧分割
            Y_DividerBuilder builder = new Y_DividerBuilder();
            builder.setBottomSideLine(true,
                    Color.WHITE,5,0,0)
                    .setRightSideLine(true,Color.WHITE,15,
                            0,0);
            return builder.create();
        }else {
            //基数->底部分割
            Y_DividerBuilder builder = new Y_DividerBuilder();
            builder.setBottomSideLine(true,
                    Color.WHITE,5,0,0);
            return  builder.create();
        }
    }
}
